package com.zara.store.client.clientmodel;

import java.math.BigDecimal;

import com.zara.store.common.ProductVO;


public class BasketLineModel implements BasketLine {
	private boolean offer = true;
	private String product;
	private int productId;
	private BigDecimal amount = BigDecimal.ONE;
	private BigDecimal normalPrice;
	private BigDecimal offerPrice;
	
	public void setOffer(boolean offer) {
		this.offer = offer;
	}
	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}
	public BigDecimal getLineTotal() {
		return amount.multiply(getPrice());
	}
	public BigDecimal getPrice() {
		return (offer)? offerPrice:normalPrice;
	}
	public BasketLineModel(RetailProduct productModel) {
		ProductVO product = productModel.getProductVO();
		this.product = product.getName();
		this.productId = product.getId();
		this.normalPrice = product.getUnitPrice();
		this.offerPrice = product.getSalePrice();
		this.offer = hasOfferPrice(); 
	}
	public String getProductName() {
		return product;
	}
	public boolean getOffer() {
		return offer;
	}
	public BigDecimal getAmount() {
		return amount;
	}
	public int getProductId() {
		return productId;
	}
	public boolean hasOfferPrice() {
		return offerPrice!=null;
	}
}
